package com.ncr.travel.appmgr.model;

import java.util.List;

import com.ncr.travel.appmgr.model.shared.AvailableGraphics;
import com.ncr.travel.appmgr.model.shared.Graphics;

/**
 * @author ng185038
 * 
 */
public class GraphicsJson extends ConfigurationJson implements Graphics {

	private List<AvailableGraphics> availableGraphics;

	/* (non-Javadoc)
	 * @see com.ncr.travel.appmgr.model.Graphics#getAvailableGraphics()
	 */
	@Override
	public List<AvailableGraphics> getAvailableGraphics() {
		return availableGraphics;
	}

	/* (non-Javadoc)
	 * @see com.ncr.travel.appmgr.model.Graphics#setAvailableGraphics(java.util.List)
	 */
	@Override
	public void setAvailableGraphics(List<AvailableGraphics> availableGraphics) {
		this.availableGraphics = availableGraphics;
	}

	public static class AvailableGraphicsJson implements AvailableGraphics {
		private String url;
		private boolean selected;

		/* (non-Javadoc)
		 * @see com.ncr.travel.appmgr.model.AvailableGraphics#getUrl()
		 */
		@Override
		public String getUrl() {
			return url;
		}

		/* (non-Javadoc)
		 * @see com.ncr.travel.appmgr.model.AvailableGraphics#setUrl(java.lang.String)
		 */
		@Override
		public void setUrl(String url) {
			this.url = url;
		}

		/* (non-Javadoc)
		 * @see com.ncr.travel.appmgr.model.AvailableGraphics#isSelected()
		 */
		@Override
		public boolean isSelected() {
			return selected;
		}

		/* (non-Javadoc)
		 * @see com.ncr.travel.appmgr.model.AvailableGraphics#setSelected(boolean)
		 */
		@Override
		public void setSelected(boolean selected) {
			this.selected = selected;
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + (selected ? 1231 : 1237);
			result = prime * result + ((url == null) ? 0 : url.hashCode());
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			AvailableGraphicsJson other = (AvailableGraphicsJson) obj;
			if (selected != other.selected)
				return false;
			if (url == null) {
				if (other.url != null)
					return false;
			} else if (!url.equals(other.url))
				return false;
			return true;
		}

		@Override
		public String toString() {
			return "AvailableGraphicsJson [url=" + url + ", selected=" + selected + "]";
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + ((availableGraphics == null) ? 0 : availableGraphics.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		GraphicsJson other = (GraphicsJson) obj;
		if (availableGraphics == null) {
			if (other.availableGraphics != null)
				return false;
		} else if (!availableGraphics.equals(other.availableGraphics))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "GraphicsJson [availableGraphics=" + availableGraphics + ", getId()=" + getId() + ", getName()=" + getName() + "]";
	}

}
